<?php
      //引入php文件
 	include 'connect-sql.php';
	   /*
 * 登陆接口
 * username
 * password
 * 
 * 返回json数据
 * 
 * */
  header('Access-Control-Allow-Origin:*'); 
  $name = $_GET['username'];
	$password = $_GET['password'];
	$link = connectSql();
	
	$query = "SELECT * FROM `user` WHERE `user`.usename = '$name' AND `user`.`password` = '$password'";
	

	$res = mysqli_query($link, $query);
	//拿到结果集返回的数据
	$row = mysqli_fetch_array($res, MYSQLI_ASSOC);
	
    $arr = [];
	if($res->num_rows){
		$arr['code']=1;
		$arr['data']=$row;
	}else{
		$arr['code']=0;
	};
	echo json_encode($arr);
?>